using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Funny.Express.CreateCode.Config
{

    public class XmlSerialHelper
    {
        public static T Deserialize<T>(string path)
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            FileStream fs = new FileStream(path, FileMode.Open);
            T t = (T)ser.Deserialize(fs);
            fs.Close();
            return t;
        }

        public static void Serialize<T>(string path, T t)
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
            ser.Serialize(fs, t);
            fs.Close();
        }

    }
}

